﻿
#region Copyright & License
// --------------------------
// Copyright 2008 Daniel Gray
// --------------------------
// This file is part of Kale.
//
// Kale is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Kale is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with Kale.  If not, see <http://www.gnu.org/licenses/>.
#endregion
#region File details
// --------------------------------------------------------
// Filename          : KaleConfigurationSection.cs
// Author            : Daniel Gray
// Created           : 15/04/2008
// --------------------------------------------------------
#endregion
            
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Kale.Core.Configuration
{
   /// <summary>
   /// Handles the Kale configuration sections in config files.
   /// </summary>
   public class KaleConfigurationSection : ConfigurationSection
   {
      /// <summary>
      /// Initializes a new instance of the <see cref="KaleConfigurationSectionHandler"/> class.
      /// </summary>
      public KaleConfigurationSection() { }

      /// <summary>
      /// Gets or sets the XML namespace.
      /// </summary>
      /// <value>The XML namespace.</value>
      [ConfigurationProperty("xmlns", IsRequired = false, DefaultValue = "https://kale.googlecode.com/svn/trunk/Kale.Core/Configuration/KaleConfiguration.xsd")]
      public string XmlNamespace
      {
         get { return (string)this["xmlns"]; }
         set { this["xmlns"] = value; }
      }

      /// <summary>
      /// Gets or sets the default database connection string.
      /// </summary>
      [ConfigurationProperty("defaultConnectionString", IsRequired = false)]
      public string DefaultConnectionString
      {
         get { return (string)this["defaultConnectionString"]; }
         set { this["defaultConnectionString"] = value; }
      }

      /// <summary>
      /// Gets or sets the disk stores.
      /// </summary>
      /// <value>The disk stores.</value>
      [ConfigurationProperty("diskStores", IsRequired = false)]
      public DiskStoreElementCollection DiskStores
      {
         get { return (DiskStoreElementCollection)this["diskStores"]; }
         set { this["diskStores"] = value; }
      }

      /// <summary>
      /// Gets or sets the album stores.
      /// </summary>
      /// <value>The album stores.</value>
      [ConfigurationProperty("albumStores", IsRequired = false)]
      public AlbumStoreElementCollection AlbumStores
      {
         get { return (AlbumStoreElementCollection)this["albumStores"]; }
         set { this["albumStores"] = value; }
      }

      /// <summary>
      /// Gets or sets the security provider configuration.
      /// </summary>
      [ConfigurationProperty("securityProvider", IsRequired=true)]
      public SecurityProviderElement SecurityProvider
      {
         get { return (SecurityProviderElement)this["securityProvider"]; }
         set { this["securityProvider"] = value; }
      }


      /// <summary>
      /// Gets or sets the session provider configuration.
      /// </summary>
      /// <value>The session provider configuration.</value>
      [ConfigurationProperty("sessionProvider", IsRequired = true)]
      public SessionProviderElement SessionProvider
      {
         get { return (SessionProviderElement)this["sessionProvider"]; }
         set { this["sessionProvider"] = value; }
      }

      /// <summary>
      /// Gets or sets the folder exclusions.
      /// </summary>
      /// <value>The folder exclusions.</value>
      [ConfigurationProperty("folderExclusions", IsRequired = false)]
      public FolderExclusionElementCollection FolderExclusions
      {
         get { return (FolderExclusionElementCollection)this["folderExclusions"]; }
         set { this["folderExclusions"] = value; }
      }

      /// <summary>
      /// Gets or sets the image sizes.
      /// </summary>
      /// <value>The image sizes.</value>
      [ConfigurationProperty("imageSizes", IsRequired = true)]
      public ImageSizeElementCollection ImageSizes
      {
         get { return (ImageSizeElementCollection)this["imageSizes"]; }
         set { this["imageSizes"] = value; }
      }

      /// <summary>
      /// Gets or sets the node caching configuration.
      /// </summary>
      /// <value>The node caching configuration.</value>
      [ConfigurationProperty("nodeCaching", IsRequired = true)]
      public NodeCachingElement NodeCaching
      {
         get { return (NodeCachingElement)this["nodeCaching"]; }
         set { this["nodeCaching"] = value; }
      }

      /// <summary>
      /// Gets or sets the image caching configuration.
      /// </summary>
      /// <value>The image caching configuration.</value>
      [ConfigurationProperty("imageCaching", IsRequired = true)]
      public ImageCachingElement ImageCaching
      {
         get { return (ImageCachingElement)this["imageCaching"]; }
         set { this["imageCaching"] = value; }
      }

      /// <summary>
      /// Gets and sets the scripting configuration.
      /// </summary>
      /// <value>The scripting configuration.</value>
      [ConfigurationProperty("scripting", IsRequired =  true)]
      public ScriptElement Scripting
      {
         get { return (ScriptElement)this["scripting"]; }
         set { this["scripting"] = value; }
      }

      /// <summary>
      /// Gets the configuration section instance with the default name out of config.
      /// </summary>
      public static KaleConfigurationSection Default
      {
         get { return ConfigurationManager.GetSection("kale") as KaleConfigurationSection; }
      }
   }
}
